From 2a98bc6a31dd136058f9068435227cf10713e0ff Mon Sep 17 00:00:00 2001 From: Owen Taylor Date: Wed, 21 Jun 2000 16:19:59 +0000 Subject: [PATCH] Remove use of libunicode in favor of new GLib functions. Wed Jun 21 11:41:43 2000 Owen Taylor * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: Remove use of libunicode in favor of new GLib functions. * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, nano-x, framebuffer. The X11 include is just a hack until we get the necessary functions in gdkcolor.h, so there is no reason to add other includes of platforms. * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert window bigger than the screen change. * gtk/testgtk.c: Revert some random changes from Elliot that had no particular point and were causing testgtkrc not to function correctly. * gdk/gdkregion-generic.h: Revert change from Elliot. Just because GdkSegment and GdkRegionBox have the same fields, it doesn't mean that 'typedef GdkSegment GdkRegionBox' results in clearer code. * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, gdk_input_translate_coordinates): Fix missed GdkObjectification --- ChangeLog | 26 ++++++++++++++++ ChangeLog.pre-2-0 | 26 ++++++++++++++++ ChangeLog.pre-2-10 | 26 ++++++++++++++++ ChangeLog.pre-2-2 | 26 ++++++++++++++++ ChangeLog.pre-2-4 | 26 ++++++++++++++++ ChangeLog.pre-2-6 | 26 ++++++++++++++++ ChangeLog.pre-2-8 | 26 ++++++++++++++++ gdk/gdkregion-generic.h | 7 +++-- gdk/x11/gdkinput-x11.c | 16 +++++----- gtk/gtkcolorsel.c | 6 ---- gtk/gtkentry.c | 35 ++++++++++----------- gtk/gtkimcontextsimple.c | 66 +++------------------------------------- gtk/gtklabel.c | 16 +++++----- gtk/gtktexttypes.c | 15 ++++----- gtk/gtkwindow.c | 5 --- gtk/testgtk.c | 7 ++--- gtk/testtext.c | 4 +-- modules/linux-fb/basic.c | 49 ++++++++--------------------- tests/testgtk.c | 7 ++--- tests/testtext.c | 4 +-- 20 files changed, 249 insertions(+), 170 deletions(-) diff --git a/ChangeLog b/ChangeLog index f9cc914892..207c30323b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-0 b/ChangeLog.pre-2-0 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-0 +++ b/ChangeLog.pre-2-0 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-2 b/ChangeLog.pre-2-2 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-2 +++ b/ChangeLog.pre-2-2 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-4 b/ChangeLog.pre-2-4 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-4 +++ b/ChangeLog.pre-2-4 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-6 b/ChangeLog.pre-2-6 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-6 +++ b/ChangeLog.pre-2-6 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/ChangeLog.pre-2-8 b/ChangeLog.pre-2-8 index f9cc914892..207c30323b 100644 --- a/ChangeLog.pre-2-8 +++ b/ChangeLog.pre-2-8 @@ -1,3 +1,29 @@ +Wed Jun 21 11:41:43 2000 Owen Taylor + + * gtk/gtkentry.c gtk/gtkimcontextsimple.c gtk/gtklabel.c + gtk/gtktexttypes.c gtk/testtext.c modules/linux-fb/basic.c: + Remove use of libunicode in favor of new GLib functions. + + * gtk/gtkcolorsel.c: Remove conditional includes for FB, win32, + nano-x, framebuffer. The X11 include is just a hack until we get + the necessary functions in gdkcolor.h, so there is no reason to + add other includes of platforms. + + * gtk/gtkwindow.c (gtk_window_compute_default_size): Revert + window bigger than the screen change. + + * gtk/testgtk.c: Revert some random changes from Elliot + that had no particular point and were causing testgtkrc + not to function correctly. + + * gdk/gdkregion-generic.h: Revert change from Elliot. Just + because GdkSegment and GdkRegionBox have the same fields, + it doesn't mean that 'typedef GdkSegment GdkRegionBox' + results in clearer code. + + * gdk/x11/gdkinput-x11.c (gdk_input_common_select_events, + gdk_input_translate_coordinates): Fix missed GdkObjectification + 2000-06-18 Elliot Lee * gdk/Makefile.am, gdk/*/Makefile.am: Fix conditionality to work the "right" way. diff --git a/gdk/gdkregion-generic.h b/gdk/gdkregion-generic.h index 017ee43e2c..659d44eb4c 100644 --- a/gdk/gdkregion-generic.h +++ b/gdk/gdkregion-generic.h @@ -45,9 +45,12 @@ SOFTWARE. #ifndef __GDK_REGION_GENERIC_H__ #define __GDK_REGION_GENERIC_H__ -#include "gdktypes.h" +typedef struct _GdkRegionBox GdkRegionBox; -typedef GdkSegment GdkRegionBox; +struct _GdkRegionBox +{ + int x1, x2, y1, y2; +}; /* * clip region diff --git a/gdk/x11/gdkinput-x11.c b/gdk/x11/gdkinput-x11.c index 04356378d8..2709c7bd7d 100644 --- a/gdk/x11/gdkinput-x11.c +++ b/gdk/x11/gdkinput-x11.c @@ -395,7 +395,7 @@ gdk_input_common_select_events(GdkWindow *window, gdk_input_common_find_events(window, gdkdev, 0, classes, &num_classes); else gdk_input_common_find_events(window, gdkdev, - ((GdkWindowPrivate *)window)->extension_events, + ((GdkWindowObject *)window)->extension_events, classes, &num_classes); XSelectExtensionEvent (gdk_display, @@ -453,14 +453,14 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, gdouble *x, gdouble *y, gdouble *pressure, gdouble *xtilt, gdouble *ytilt) { - GdkDrawablePrivate *drawable_priv; + GdkWindowImplX11 *impl; int x_axis, y_axis, pressure_axis, xtilt_axis, ytilt_axis; double device_width, device_height; double x_offset, y_offset, x_scale, y_scale; - drawable_priv = (GdkDrawablePrivate *) input_window->window; + impl = GDK_WINDOW_IMPL_X11 (((GdkWindowObject *) input_window->window)->impl); x_axis = gdkdev->axis_for_use[GDK_AXIS_X]; y_axis = gdkdev->axis_for_use[GDK_AXIS_Y]; @@ -486,26 +486,26 @@ gdk_input_translate_coordinates (GdkDevicePrivate *gdkdev, double device_aspect = (device_height*gdkdev->axes[y_axis].resolution) / (device_width*gdkdev->axes[x_axis].resolution); - if (device_aspect * drawable_priv->width >= drawable_priv->height) + if (device_aspect * impl->width >= impl->height) { /* device taller than window */ - x_scale = drawable_priv->width / device_width; + x_scale = impl->width / device_width; y_scale = (x_scale * gdkdev->axes[x_axis].resolution) / gdkdev->axes[y_axis].resolution; x_offset = 0; y_offset = -(device_height * y_scale - - drawable_priv->height)/2; + impl->height)/2; } else { /* window taller than device */ - y_scale = drawable_priv->height / device_height; + y_scale = impl->height / device_height; x_scale = (y_scale * gdkdev->axes[y_axis].resolution) / gdkdev->axes[x_axis].resolution; y_offset = 0; - x_offset = - (device_width * x_scale - drawable_priv->width)/2; + x_offset = - (device_width * x_scale - impl->width)/2; } } diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index c43c18438c..26d34078e8 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -29,12 +29,6 @@ #if defined (GDK_WINDOWING_X11) #include "x11/gdkx.h" -#elif defined (GDK_WINDOWING_WIN32) -#include "win32/gdkwin32.h" -#elif defined (GDK_WINDOWING_NANOX) -#include "nanox/gdkprivate-nanox.h" -#elif defined (GDK_WINDOWING_FB) -#include "linux-fb/gdkprivate-fb.h" #endif #include "gdk/gdkkeysyms.h" #include "gtkcolorsel.h" diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 25e2dbdc9b..6df9f77e35 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -36,7 +36,6 @@ #include "gtkstyle.h" #include -#include #include #define MIN_ENTRY_WIDTH 150 @@ -1172,8 +1171,6 @@ gtk_entry_ensure_layout (GtkEntry *entry) { GtkWidget *widget = GTK_WIDGET (entry); - PangoAttrList *attrs; - if (!entry->layout) { entry->layout = gtk_widget_create_pango_layout (widget); @@ -1216,10 +1213,10 @@ gtk_entry_draw_text (GtkEntry *entry) { gint *ranges; gint n_ranges, i; - gint start_index = unicode_offset_to_index (entry->text, - MIN (editable->selection_start_pos, editable->selection_end_pos)); - gint end_index = unicode_offset_to_index (entry->text, - MAX (editable->selection_start_pos, editable->selection_end_pos)); + gint start_index = g_utf8_offset_to_pointer (entry->text, + MIN (editable->selection_start_pos, editable->selection_end_pos)) - entry->text; + gint end_index = g_utf8_offset_to_pointer (entry->text, + MAX (editable->selection_start_pos, editable->selection_end_pos)) - entry->text; GtkStateType selected_state = editable->has_selection ? GTK_STATE_SELECTED : GTK_STATE_ACTIVE; GdkRegion *clip_region = gdk_region_new (); @@ -1335,7 +1332,7 @@ gtk_entry_find_position (GtkEntry *entry, pango_layout_line_x_to_index (line, x * PANGO_SCALE, &index, &trailing); if (trailing) - index = unicode_next_utf8 (entry->text + index) - entry->text; + index = g_utf8_next_char (entry->text + index) - entry->text; return index; } @@ -1352,7 +1349,7 @@ gtk_entry_get_cursor_locations (GtkEntry *entry, gtk_entry_ensure_layout (entry); - index = unicode_offset_to_index (entry->text, editable->current_pos); + index = g_utf8_offset_to_pointer (entry->text, editable->current_pos) - entry->text; pango_layout_get_cursor_pos (entry->layout, index, &strong_pos, &weak_pos); if (strong_x) @@ -1467,7 +1464,7 @@ gtk_entry_insert_text (GtkEditable *editable, if (new_text_length < 0) new_text_length = strlen (new_text); - n_chars = unicode_strlen (new_text, new_text_length); + n_chars = g_utf8_strlen (new_text, new_text_length); if (entry->text_max_length > 0 && n_chars + entry->text_length > entry->text_max_length) { gdk_beep (); @@ -1497,7 +1494,7 @@ gtk_entry_insert_text (GtkEditable *editable, entry->text = g_realloc (entry->text, entry->text_size); } - index = unicode_offset_to_index (entry->text, *position); + index = g_utf8_offset_to_pointer (entry->text, *position) - entry->text; g_memmove (entry->text + index + new_text_length, entry->text + index, entry->n_bytes - index); memcpy (entry->text + index, new_text, new_text_length); @@ -1544,8 +1541,8 @@ gtk_entry_delete_text (GtkEditable *editable, (start_pos >= 0) && (end_pos <= entry->text_length)) { - gint start_index = unicode_offset_to_index (entry->text, start_pos); - gint end_index = unicode_offset_to_index (entry->text, end_pos); + gint start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text; + gint end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text; g_memmove (entry->text + start_index, entry->text + end_index, entry->n_bytes - end_index); entry->text_length -= (end_pos - start_pos); @@ -1597,8 +1594,8 @@ gtk_entry_get_chars (GtkEditable *editable, start_pos = MIN (entry->text_length, start_pos); end_pos = MIN (entry->text_length, end_pos); - start_index = unicode_offset_to_index (entry->text, start_pos); - end_index = unicode_offset_to_index (entry->text, end_pos); + start_index = g_utf8_offset_to_pointer (entry->text, start_pos) - entry->text; + end_index = g_utf8_offset_to_pointer (entry->text, end_pos) - entry->text; return g_strndup (entry->text + start_index, end_index - start_index); } @@ -1613,7 +1610,7 @@ gtk_entry_move_cursor (GtkEditable *editable, entry = GTK_ENTRY (editable); - index = unicode_offset_to_index (entry->text, editable->current_pos); + index = g_utf8_offset_to_pointer (entry->text, editable->current_pos) - entry->text; /* Horizontal motion */ @@ -1636,7 +1633,7 @@ gtk_entry_move_cursor_visually (GtkEditable *editable, entry = GTK_ENTRY (editable); - index = unicode_offset_to_index (entry->text, editable->current_pos); + index = g_utf8_offset_to_pointer (entry->text, editable->current_pos) - entry->text; gtk_entry_ensure_layout (entry); @@ -1659,12 +1656,12 @@ gtk_entry_move_cursor_visually (GtkEditable *editable, break; if (new_trailing) - index = unicode_next_utf8 (entry->text + new_index) - entry->text; + index = g_utf8_next_char (entry->text + new_index) - entry->text; else index = new_index; } - editable->current_pos = unicode_index_to_offset (entry->text, index); + editable->current_pos = g_utf8_pointer_to_offset (entry->text, entry->text + index); } static void diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c index 03ddcc3310..bd1f282307 100644 --- a/gtk/gtkimcontextsimple.c +++ b/gtk/gtkimcontextsimple.c @@ -17,7 +17,6 @@ * Boston, MA 02111-1307, USA. */ -#include #include #include "gtksignal.h" #include "gtkimcontextsimple.h" @@ -781,71 +780,14 @@ gtk_im_context_simple_new (void) return GTK_IM_CONTEXT (gtk_type_new (GTK_TYPE_IM_CONTEXT_SIMPLE)); } -/** - * unicode_guchar4_to_utf8: - * @ch: a ISO10646 character code - * @out: output buffer, must have at least 6 bytes of space. - * - * Convert a single character to utf8 - * - * Return value: number of bytes written - **/ -static int -ucs4_to_utf8 (unicode_char_t c, char *outbuf) -{ - size_t len = 0; - int first; - int i; - - if (c < 0x80) - { - first = 0; - len = 1; - } - else if (c < 0x800) - { - first = 0xc0; - len = 2; - } - else if (c < 0x10000) - { - first = 0xe0; - len = 3; - } - else if (c < 0x200000) - { - first = 0xf0; - len = 4; - } - else if (c < 0x4000000) - { - first = 0xf8; - len = 5; - } - else - { - first = 0xfc; - len = 6; - } - - for (i = len - 1; i > 0; --i) - { - outbuf[i] = (c & 0x3f) | 0x80; - c >>= 6; - } - outbuf[0] = c | first; - - return len; -} - static void gtk_im_context_simple_commit_char (GtkIMContext *context, - unicode_char_t ch) + gunichar ch) { - gchar buf[7]; + gchar buf[10]; gint len; - len = ucs4_to_utf8 (ch, buf); + len = g_unichar_to_utf8 (ch, buf); buf[len] = '\0'; gtk_signal_emit_by_name (GTK_OBJECT (context), "commit", &buf); @@ -878,7 +820,7 @@ gtk_im_context_simple_filter_keypress (GtkIMContext *context, GtkIMContextSimple *context_simple = GTK_IM_CONTEXT_SIMPLE (context); GtkComposeSeq *seq; - unicode_char_t ch; + gunichar ch; int n_compose = 0; int i; diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c index 47b9680639..dde3042dd5 100644 --- a/gtk/gtklabel.c +++ b/gtk/gtklabel.c @@ -29,7 +29,6 @@ #include "gdk/gdkkeysyms.h" #include "gdk/gdki18n.h" #include -#include enum { @@ -333,13 +332,13 @@ gtk_label_pattern_to_attrs (GtkLabel *label) { while (*p && *q && *q != '_') { - p = unicode_next_utf8 (p); + p = g_utf8_next_char (p); q++; } start = p; while (*p && *q && *q == '_') { - p = unicode_next_utf8 (p); + p = g_utf8_next_char (p); q++; } @@ -647,7 +646,7 @@ gtk_label_parse_uline (GtkLabel *label, /* Convert text to wide characters */ new_str = g_new (gchar, strlen (str) + 1); - pattern = g_new (gchar, unicode_strlen (str, -1) + 1); + pattern = g_new (gchar, g_utf8_strlen (str, -1) + 1); underscore = FALSE; @@ -657,17 +656,18 @@ gtk_label_parse_uline (GtkLabel *label, while (*src) { - unicode_char_t c; + gunichar c; gchar *next_src; - - next_src = unicode_get_utf8 (src, &c); - if (!next_src) + + c = g_utf8_get_char (src); + if (c == (gunichar)-1) { g_warning ("Invalid input string"); g_free (new_str); g_free (pattern); return GDK_VoidSymbol; } + next_src = g_utf8_next_char (src); if (underscore) { diff --git a/gtk/gtktexttypes.c b/gtk/gtktexttypes.c index cf215af298..1dfa16bfc4 100644 --- a/gtk/gtktexttypes.c +++ b/gtk/gtktexttypes.c @@ -47,8 +47,6 @@ gtk_text_view_tab_array_unref(GtkTextTabArray *tab_array) * API, eventually should just use libunicode/Pango directly) */ -#include - #if 0 static void trigger_efence(const gchar *str, gint len) @@ -73,7 +71,7 @@ gint gtk_text_view_num_utf_chars(const gchar *str, gint len) { trigger_efence(str, len); - return unicode_strlen(str, len); + return g_utf8_strlen(str, len); } /* FIXME we need a version of this function with error handling, so we @@ -82,19 +80,18 @@ gtk_text_view_num_utf_chars(const gchar *str, gint len) gint gtk_text_utf_to_unichar(const gchar *str, GtkTextUniChar *chPtr) { - unicode_char_t ch; - gchar *end; + gunichar ch; - end = unicode_get_utf8(str, &ch); + ch = g_utf8_get_char (str); - if (end == NULL) + if (ch == (gunichar)-1) g_error("Bad UTF8, need to add some error checking so this doesn't crash the program"); *chPtr = ch; trigger_efence(str, end - str); - return end - str; + return g_utf8_next_char (str) - str; } gchar* @@ -104,7 +101,7 @@ gtk_text_utf_prev(const gchar *str, const gchar *start) trigger_efence(start, str - start); - retval = unicode_previous_utf8(start, str); + retval = g_utf8_find_prev_char (start, str); return retval; } diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c index 11a0d83cff..1be60d5b03 100644 --- a/gtk/gtkwindow.c +++ b/gtk/gtkwindow.c @@ -33,8 +33,6 @@ #include "x11/gdkx.h" #elif defined (GDK_WINDOWING_WIN32) #include "win32/gdkwin32.h" -#elif defined (GDK_WINDOWING_FB) -#include "linux-fb/gdkfb.h" #elif defined (GDK_WINDOWING_NANOX) #include "nanox/gdkprivate-nanox.h" #endif @@ -1828,9 +1826,6 @@ gtk_window_compute_default_size (GtkWindow *window, *width = info->width > 0 ? info->width : *width; *height = info->height > 0 ? info->height : *height; } - - *width = MIN(*width, gdk_screen_width()); - *height = MIN(*width, gdk_screen_height()); } /* Constrain a window size to obey the hints passed in geometry diff --git a/gtk/testgtk.c b/gtk/testgtk.c index accc42d7cf..04e6c0822a 100644 --- a/gtk/testgtk.c +++ b/gtk/testgtk.c @@ -8510,7 +8510,7 @@ do_exit (GtkWidget *widget, GtkWidget *window) gtk_main_quit (); } -GtkWidget * +void create_main_window (void) { struct { @@ -8627,7 +8627,6 @@ create_main_window (void) for (i = 0; i < nbuttons; i++) { button = gtk_button_new_with_label (buttons[i].label); - gtk_widget_set_name(button, buttons[i].label); if (buttons[i].func) gtk_signal_connect (GTK_OBJECT (button), "clicked", @@ -8654,8 +8653,6 @@ create_main_window (void) gtk_widget_grab_default (button); gtk_widget_show_all (window); - - return window; } int @@ -8685,7 +8682,9 @@ main (int argc, char *argv[]) "debug_msg", 1, GTK_TYPE_STRING, "GtkWidgetClass 9 test"); + create_main_window (); + gtk_main (); return 0; diff --git a/gtk/testtext.c b/gtk/testtext.c index 3393596cdf..fad48f0399 100644 --- a/gtk/testtext.c +++ b/gtk/testtext.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -608,7 +607,6 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename) { gint count; char *leftover, *next; - unicode_char_t wc; int to_read = 2047 - remaining; count = fread (buf + remaining, 1, to_read, f); @@ -621,7 +619,7 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename) if (!*leftover) break; - next = unicode_get_utf8 (next, &wc); + next = g_utf8_next_char (next); } gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); diff --git a/modules/linux-fb/basic.c b/modules/linux-fb/basic.c index 51546f0f31..880c4139eb 100644 --- a/modules/linux-fb/basic.c +++ b/modules/linux-fb/basic.c @@ -24,7 +24,6 @@ #include #include #include "gdkprivate-fb.h" -#include #include PangoGlyph @@ -85,22 +84,6 @@ static PangoGlyph conv_ucs4 (CharCache *cache, Charset *charset, const char *input); -/* From pango/utils.h */ -typedef guint16 GUChar2; -typedef guint32 GUChar4; - -gboolean _pango_utf8_iterate (const char *cur, - const char **next, - GUChar4 *wc_out); -GUChar2 *_pango_utf8_to_ucs2 (const char *str, - gint len); -GUChar4 *_pango_utf8_to_ucs4 (const char *str, - int len); -int _pango_guchar4_to_utf8 (GUChar4 c, - char *outbuf); -int _pango_utf8_len (const char *str, - gint limit); - #include "tables-big.i" static PangoEngineInfo script_engines[] = { @@ -189,7 +172,7 @@ char_cache_free (CharCache *cache) } PangoGlyph -find_char (CharCache *cache, PangoFont *font, GUChar4 wc, const char *input) +find_char (CharCache *cache, PangoFont *font, gunichar wc, const char *input) { return FT_Get_Char_Index(PANGO_FB_FONT(font)->ftf, wc); } @@ -231,15 +214,13 @@ conv_8bit (CharCache *cache, { iconv_t cd; char outbuf; - const char *p; const char *inptr = input; size_t inbytesleft; char *outptr = &outbuf; size_t outbytesleft = 1; - _pango_utf8_iterate (input, &p, NULL); - inbytesleft = p - input; + inbytesleft = g_utf8_next_char (input) - input; cd = find_converter (cache, charset); @@ -255,15 +236,13 @@ conv_euc (CharCache *cache, { iconv_t cd; char outbuf[2]; - const char *p; const char *inptr = input; size_t inbytesleft; char *outptr = outbuf; size_t outbytesleft = 2; - _pango_utf8_iterate (input, &p, NULL); - inbytesleft = p - input; + inbytesleft = g_utf8_next_char (input) - input; cd = find_converter (cache, charset); @@ -280,10 +259,7 @@ conv_ucs4 (CharCache *cache, Charset *charset, const char *input) { - GUChar4 wc; - - unicode_get_utf8 (input, &wc); - return wc; + return g_utf8_get_char (input); } static void @@ -332,7 +308,6 @@ basic_engine_shape (PangoFont *font, int n_chars; int i; const char *p; - const char *next; CharCache *cache; @@ -343,19 +318,19 @@ basic_engine_shape (PangoFont *font, cache = get_char_cache (font); - n_chars = unicode_strlen (text, length); + n_chars = g_utf8_strlen (text, length); pango_glyph_string_set_size (glyphs, n_chars); p = text; for (i=0; i < n_chars; i++) { - GUChar4 wc; + gunichar wc; FriBidiChar mirrored_ch; PangoGlyph index; char buf[6]; const char *input; - _pango_utf8_iterate (p, &next, &wc); + wc = g_utf8_get_char (p); input = p; if (analysis->level % 2) @@ -363,7 +338,7 @@ basic_engine_shape (PangoFont *font, { wc = mirrored_ch; - _pango_guchar4_to_utf8 (wc, buf); + g_unichar_to_utf8 (wc, buf); input = buf; } @@ -378,7 +353,7 @@ basic_engine_shape (PangoFont *font, { set_glyph (font, glyphs, i, p - text, index); - if (unicode_type (wc) == UNICODE_NON_SPACING_MARK) + if (g_unichar_type (wc) == G_UNICODE_NON_SPACING_MARK) { if (i > 0) { @@ -402,7 +377,7 @@ basic_engine_shape (PangoFont *font, set_glyph (font, glyphs, i, p - text, pango_fb_get_unknown_glyph (font)); } - p = next; + p = g_utf8_next_char (p); } /* Simple bidi support... may have separate modules later */ @@ -434,13 +409,13 @@ basic_engine_get_coverage (PangoFont *font, { CharCache *cache = get_char_cache (font); PangoCoverage *result = pango_coverage_new (); - GUChar4 wc; + gunichar wc; for (wc = 0; wc < 65536; wc++) { char buf[6]; - _pango_guchar4_to_utf8 (wc, buf); + g_unichar_to_utf8 (wc, buf); if (find_char (cache, font, wc, buf)) pango_coverage_set (result, wc, PANGO_COVERAGE_EXACT); } diff --git a/tests/testgtk.c b/tests/testgtk.c index accc42d7cf..04e6c0822a 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -8510,7 +8510,7 @@ do_exit (GtkWidget *widget, GtkWidget *window) gtk_main_quit (); } -GtkWidget * +void create_main_window (void) { struct { @@ -8627,7 +8627,6 @@ create_main_window (void) for (i = 0; i < nbuttons; i++) { button = gtk_button_new_with_label (buttons[i].label); - gtk_widget_set_name(button, buttons[i].label); if (buttons[i].func) gtk_signal_connect (GTK_OBJECT (button), "clicked", @@ -8654,8 +8653,6 @@ create_main_window (void) gtk_widget_grab_default (button); gtk_widget_show_all (window); - - return window; } int @@ -8685,7 +8682,9 @@ main (int argc, char *argv[]) "debug_msg", 1, GTK_TYPE_STRING, "GtkWidgetClass 9 test"); + create_main_window (); + gtk_main (); return 0; diff --git a/tests/testtext.c b/tests/testtext.c index 3393596cdf..fad48f0399 100644 --- a/tests/testtext.c +++ b/tests/testtext.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include @@ -608,7 +607,6 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename) { gint count; char *leftover, *next; - unicode_char_t wc; int to_read = 2047 - remaining; count = fread (buf + remaining, 1, to_read, f); @@ -621,7 +619,7 @@ fill_file_buffer (GtkTextBuffer *buffer, const char *filename) if (!*leftover) break; - next = unicode_get_utf8 (next, &wc); + next = g_utf8_next_char (next); } gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); -- 2.30.2